<!DOCTYPE HTML>
<html>
<body>
<table id="rooms" border="1" style="width:800px">
	<tr>
	  <td>RoomId</td>
	  <td>Name</td> 
	  <td>Setpoint</td>
	  <td>Temperature</td>
	  <td>Humidity</td>
	  <td>Occupied</td>
	  <td>ActuatorOutput</td>
	  <td>Time</td>
	</tr>
</table>

<script>
function addRow(jsontext)
{
	var table = document.getElementById("rooms");
	for(var i = table.rows.length - 1; i > 0; i--)
	{
		table.deleteRow(i);
	}
	
	var apartment = JSON.parse(jsontext);
	var row = table.insertRow(1);
	var cell1 = row.insertCell(0);
	var cell2 = row.insertCell(1);
	var cell3 = row.insertCell(2);
	var cell4 = row.insertCell(3);
	var cell5 = row.insertCell(4);
	var cell6 = row.insertCell(5);
	var cell7 = row.insertCell(6);
	var cell8 = row.insertCell(7);
	cell1.innerHTML = apartment.rooms[0].id;
	cell2.innerHTML = apartment.rooms[0].name;
	cell3.innerHTML = apartment.rooms[0].actualTemperatureSetpoint;
	cell4.innerHTML = apartment.rooms[0].actualTemperature;
	cell5.innerHTML = apartment.rooms[0].actualHumidity;
	cell6.innerHTML = apartment.rooms[0].actualOccupied;
	cell7.innerHTML = apartment.rooms[0].actuators[0].activeOutput;
	var d = new Date(apartment.rooms[0].sensors[0].lastActiveTimeInMillis);
	cell8.innerHTML = "" + d.getDate() + "." + (d.getMonth() + 1) + "." + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
}

function deleteRow()
{
	document.getElementById("rooms").deleteRow(0);
}
</script>

</body>
</html>